<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row type="flex">
          <a-col>
            <a-button icon="plus" style="margin-right: 20px" type="primary" @click="openAdd()">新增</a-button>
            <a-divider style="margin-right: 20px" type="vertical" />
          </a-col>
          <a-col :md="4" :sm="8">
            <a-form-item label="所在地">
              <a-select v-model="queryParam.location" placeholder="请选择类别">
                <a-select-option v-for="(i,index) in locationList" :key="index" :value="i.key">{{ i.name }}
                </a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :md="4" :sm="8" style="margin-left: 15px">
            <a-form-item label="项目状态">
              <a-select v-model="queryParam.projectStatus" placeholder="请选择项目状态">
                <a-select-option v-for="(i,index) in statusList" :key="index" :value="i.key">{{ i.name }}
                </a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8" style="margin-left: 15px">
            <a-form-item label="时间从">
              <a-range-picker v-model="createTime"
                              :mode="['year', 'year']"
                              :placeholder="['开始年份', '结束年份']"
                              format="YYYY"
                              valueFormat="YYYY"
                              :open="isRangePickerOpen"
                              @openChange="handleOpenChange"
                              @panelChange="handlePanelChange"
              />
            </a-form-item>
          </a-col>
          <a-col flex="auto" style="margin-left: 15px">
            <span class="table-page-search-submitButtons" style="float: left; overflow: hidden;margin-right: 20px">
              <a-button icon="search" style="margin-left: 10px" type="primary" @click="searchQuery">查询</a-button>
              <a-popover :overlayStyle="{background: 'white'}" placement="topLeft">
                <template slot="content">
                  <a-icon theme="twoTone" two-tone-color="#52c41a" type="exclamation-circle" /><span
                  style="margin-left: 5px">可以点击重置来重新筛选结果</span>
                </template>
                <a-button
                  icon="reload"
                  style="margin-left: 8px"
                  @click="searchReset"
                >重置</a-button>
              </a-popover>

            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <div>
      <a-table
        ref="table"
        :columns="columns"
        :dataSource="dataSource"
        :loading="loading"
        :pagination="ipagination"
        bordered
        rowKey="id"
        size="middle"
        @change="handleTableChange">
        <span slot="type" slot-scope="text, record">
          <a-tag v-if="text == '0'" color="red">国内</a-tag>
          <a-tag v-if="text == '1'" color="blue">国际</a-tag>
        </span>
        <span slot="action" slot-scope="text, record">
          <a-button style="margin-right: 10px" type="primary" @click="handleEdit(record)">
            编辑
          </a-button>
            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
              <a-button>
                删除
              </a-button>
            </a-popconfirm>
        </span>
      </a-table>
      <!--      <map-data-modal ref="modalForm" @ok="modalFormOk"></map-data-modal>-->
      <dbl-high-modal ref="modalForm" @ok="modalFormOk"></dbl-high-modal>
    </div>
  </a-card>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction } from '@api/manage'
import DblHighModal from '@views/dataVisualization/components/dblHighModal'

const date = new Date()
const defaultYear = '2022'
export default {
  name: 'currentEngConsumption',
  components: { DblHighModal },
  mixins: [JeecgListMixin],
  data() {
    return {
      statusList: [
        { name: '拟建', key: '拟建' },
        { name: '在建', key: '在建' }
      ],
      locationList: [
        { name: '上海市化工区', key: '上海市化工区' },
        { name: '上海市金山区', key: '上海市金山区' },
        { name: '上海市宝山区', key: '上海市宝山区' },
        { name: '上海市奉贤区', key: '上海市奉贤区' },
        { name: '上海市闵行区', key: '上海市闵行区' },
        { name: '临港管委会', key: '临港管委会' },
        { name: '上海市浦东新区', key: '上海市浦东新区' }
      ],
      createTime: [],
      isRangePickerOpen: false,
      confirmLoading: false,
      title: '',
      visible: false,
      dataSource: [],
      form: this.$form.createForm(this),
      dialogStyle: {
        top: '200px'
        // right:"20px",
      },
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      columns: [
        {
          title: '所在地',
          align: 'center',
          dataIndex: 'location',
          width: 130
        },
        {
          title: '项目名称',
          align: 'left',
          dataIndex: 'entryName'
        },
        {
          title: '项目状态',
          align: 'center',
          dataIndex: 'projectStatus',
          width: 80
        },
        {
          title: '开工时间',
          align: 'center',
          dataIndex: 'commencementTime',
          width: 120
        },
        {
          title: '投产时间',
          align: 'center',
          dataIndex: 'productionTime',
          width: 120
        },
        {
          title: '总投资（亿元）',
          align: 'center',
          dataIndex: 'totalInvestment',
          width: 130
        },
        {
          title: '完成投资（亿元）',
          align: 'center',
          dataIndex: 'completionInvestment',
          width: 130
        },
        {
          title: '年综合能耗 （万吨标准煤，含原料用能）',
          align: 'center',
          width: 300,
          children: [
            {
              title: '设计能耗',
              dataIndex: 'designEnergyConsumption',
              key: 'building',
              width: 138,
              align: 'center'
            },
            {
              title: '“十四五”新增能耗',
              dataIndex: 'newEnergyConsumption',
              key: 'number',
              width: 138,
              align: 'center'
            }
          ]
        },
        {
          title: '年原料用能消费量',
          align: 'center',
          dataIndex: 'designEnergyConsumption',
          width: 130
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' },
          width: 200
        }
      ],
      url: {
        list: '/carbon/twoHighProjects/list',
        delete: '/carbon/twoHighProjects/delete'
      }
    }
  },
  created() {
  },
  mounted() {
  },
  methods: {
    searchReset() {
      this.queryParam = {}
      this.loadData(1);
      this.createTime = []
    },
    openAdd() {
      this.$refs.modalForm.add()
      this.$refs.modalForm.title = '新增'
      this.$refs.modalForm.disableSubmit = false
    },
    handlePanelChange(value) {
      this.isRangePickerOpen = false
      this.createTime = value
      this.queryParam.startYear = value[0].format('YYYY')
      this.queryParam.endYear = value[1].format('YYYY')
    },
    handleOpenChange(open) {
      this.isRangePickerOpen = open
    },
    handleRangePickerChange(dates, dateStrings) {
      // 当用户选择了日期（不只是更改面板的模式）时关闭面板
      if (dates) {
        this.isRangePickerOpen = false
      }
    }
  }
}
</script>

<style scoped>

</style>